package com.yeban.bams.server;

import com.yeban.bams.service.Bank;

import javax.swing.*;
import java.awt.*;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/11/6
 */
public class ATMServer extends JFrame {

    // Panel
    ServerPanel serverPanel;
    public final RankPanel rankPanel;
    public final LogPanel logPanel;
    public final AccountPanel accountPanel;
    public final DataPanel dataPanel;

    // 共同资源
    Bank bank;

    public ATMServer() {
        // 设置窗体信息
        this.setTitle("BAMS Server");
        this.setSize(500, 650);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);

        // 初始化共同资源
        bank = Bank.getInstance();

        // 实例化JPanel
        serverPanel = new ServerPanel(this);
        rankPanel = new RankPanel(this);
        logPanel = new LogPanel();
        accountPanel = new AccountPanel(this);
        dataPanel = new DataPanel(this);

        // 设置窗体的布局方式为"卡片式布局"
        Container container = this.getContentPane();
        container.setLayout(new CardLayout());
        container.add("serverPanel", serverPanel);
        container.add("rankPanel", rankPanel);
        container.add("logPanel", logPanel);
        container.add("accountPanel", accountPanel);
        container.add("dataPanel", dataPanel);
    }

    public static void main(String[] args) {
        new ATMServer().setVisible(true);
    }
}
